#include"graph.h"

using namespace std;

void test1();
void test2();
void test3();
void test4();

int main(int argc,char *argv[])
{
    test1();
    test2();
    test3();
    test4();
    return 0;
}

void test1()
{
    cout<<"测试无向有权邻接矩阵图"<<endl;
    UdGraph<int> g1(1);
    g1.insertVertex(5);
    g1.insertVertex(2);
    g1.insertVertex(7);
    g1.insertVertex(6);
    g1.insertVertex(3);
    g1.insertVertex(2);///已存在顶点
    g1.insertEdge(3,5,2);
    g1.insertEdge(2,3,9);
    g1.insertEdge(7,6,6);
    g1.insertEdge(6,3,8);
    g1.insertEdge(2,5,4);
    g1.insertEdge(5,3,4);///已存在边
    g1.insertEdge(7,5,9);
    g1.insertEdge(2,4,4);///不存在顶点
    g1.deleteVertex(3);
    g1.deleteVertex(4);///不存在顶点
    g1.deleteEdge(5,2);
    g1.deleteEdge(7,5);
    g1.deleteEdge(5,6);///不存在边
    g1.deleteEdge(3,5);///不存在顶点
    g1.deleteEdge(5,4);///不存在顶点
    cout<<g1.containVertex(6)<<endl;
    cout<<g1.containVertex(3)<<endl;///不存在顶点
    cout<<g1.containVertex(4)<<endl;///不存在顶点
    cout<<g1.containEdge(6,7)<<endl;
    cout<<g1.containEdge(6,3)<<endl;///不存在顶点
    g1.listVertexes();
    g1.listEdges();
    cout<<"test end"<<endl;
}
void test2()
{
    cout<<"测试无向无权邻接表图"<<endl;
    UdGraph<int> g1(0);
    g1.insertVertex(5);
    g1.insertVertex(2);
    g1.insertVertex(7);
    g1.insertVertex(6);
    g1.insertVertex(3);
    g1.insertVertex(2);///已存在顶点
    g1.insertEdge(3,5);
    g1.insertEdge(2,3);
    g1.insertEdge(7,6);
    g1.insertEdge(6,3);
    g1.insertEdge(2,5);
    g1.insertEdge(5,3);///已存在边
    g1.insertEdge(7,5);
    g1.insertEdge(2,4);///不存在顶点
    g1.deleteVertex(3);
    g1.deleteVertex(4);///不存在顶点
    g1.deleteEdge(5,2);
    g1.deleteEdge(7,5);
    g1.deleteEdge(5,6);///不存在边
    g1.deleteEdge(3,5);///不存在顶点
    g1.deleteEdge(5,4);///不存在顶点
    cout<<g1.containVertex(6)<<endl;
    cout<<g1.containVertex(3)<<endl;///不存在顶点
    cout<<g1.containVertex(4)<<endl;///不存在顶点
    cout<<g1.containEdge(6,7)<<endl;
    cout<<g1.containEdge(6,3)<<endl;///不存在边
    g1.listVertexes();
    g1.listEdges();
    cout<<"test end"<<endl;
}
void test3()
{
    cout<<"测试有向有权邻接矩阵图"<<endl;
    DGraph<int> g1(1);
    g1.insertVertex(5);
    g1.insertVertex(2);
    g1.insertVertex(7);
    g1.insertVertex(6);
    g1.insertVertex(3);
    g1.insertVertex(2);///已存在顶点
    g1.insertEdge(3,5,2);
    g1.insertEdge(2,3,9);
    g1.insertEdge(7,6,6);
    g1.insertEdge(6,3,8);
    g1.insertEdge(2,5,4);
    g1.insertEdge(5,3,4);
    g1.insertEdge(7,5,9);
    g1.insertEdge(2,4,4);///不存在顶点
    g1.deleteVertex(3);
    g1.deleteVertex(4);///不存在顶点
    g1.deleteEdge(5,2);///不存在边
    g1.deleteEdge(7,5);
    g1.deleteEdge(5,6);///不存在边
    g1.deleteEdge(3,5);///不存在顶点
    g1.deleteEdge(5,4);///不存在顶点
    cout<<g1.containVertex(6)<<endl;
    cout<<g1.containVertex(3)<<endl;///不存在顶点
    cout<<g1.containVertex(4)<<endl;///不存在顶点
    cout<<g1.containEdge(6,7)<<endl;///不存在边
    cout<<g1.containEdge(6,3)<<endl;///不存在边
    g1.listVertexes();
    g1.listEdges();
    cout<<"test end"<<endl;
}
void test4()
{
    cout<<"测试有向无权邻接表图"<<endl;
    DGraph<int> g1(0);
    g1.insertVertex(5);
    g1.insertVertex(2);
    g1.insertVertex(7);
    g1.insertVertex(6);
    g1.insertVertex(3);
    g1.insertVertex(2);///已存在顶点
    g1.insertEdge(3,5);
    g1.insertEdge(2,3);
    g1.insertEdge(7,6);
    g1.insertEdge(6,3);
    g1.insertEdge(2,5);
    g1.insertEdge(5,3);
    g1.insertEdge(7,5);
    g1.insertEdge(2,4);///不存在顶点
    g1.deleteVertex(3);
    g1.deleteVertex(4);///不存在顶点
    g1.deleteEdge(5,2);///不存在边
    g1.deleteEdge(7,5);
    g1.deleteEdge(5,6);///不存在边
    g1.deleteEdge(3,5);///不存在顶点
    g1.deleteEdge(5,4);///不存在顶点
    cout<<g1.containVertex(6)<<endl;
    cout<<g1.containVertex(3)<<endl;///不存在顶点
    cout<<g1.containVertex(4)<<endl;///不存在顶点
    cout<<g1.containEdge(6,7)<<endl;///不存在边
    cout<<g1.containEdge(6,3)<<endl;///不存在边
    g1.listVertexes();
    g1.listEdges();
    cout<<"test end"<<endl;
}

